﻿using System;
using System.Collections;
using System.Web.Mvc;
using MvcApplication1.Utility;
using RIMS.Lib.Manager;
using RIMS.Lib.Models;

namespace MvcApplication1.Actions.EmployeeActions
{
    public class Create : Common, ICreate
    {
        public Hashtable Execute(Employee employee, FormCollection collection)
        {
            Hashtable result = new Hashtable();
            result[Tools.IS_ERROR] = true;
            try
            {
                employee = new EmployeeManager().Save(employee);

                if (employee == null)
                {
                    result[Tools.MESSAGE] = "Data cannot save";
                    return result;
                }
                result[Tools.ENTITY] = GetFlexiGrid(employee);
                result[Tools.MESSAGE] = "Saved successfully";
                result[Tools.IS_ERROR] = false;
                return result;
            }
            catch (Exception ex)
            {

                return result;
            }
        }
    }
}